home *** CD-ROM | disk | FTP | other *** search
- source Player.tcl
- source Game.tcl
-
- otcl oserver init
-
- puts -nonewline "Please enter your name: "
- gets stdin name
-
- if {$name == ""} {
- puts "Goodbye..."
- exit
- }
-
- puts -nonewline "$name, please enter the address of the player server: "
- gets stdin playerServerAddress
- if {$playerServerAddress == ""} {
- puts "Goodbye ..."
- exit
- }
-
- otcl remoteClass PlayerServer $playerServerAddress
-
-
- set me [otclNew Player $name]
-
- set playerList {}
-
- proc quitProc {} {
- global me
- PlayerServer playerNotAvailable $me
- exit
- }
-
- proc selectedProc {} {
-
- global me
- global playerList
-
- foreach o [.clist.list curselection] {
- set game [[lindex [lindex $playerList $o] 1] challenge $me]
- [otclNew Game X $me] setOpponent $game
- }
-
- destroy .clist
- .challenge configure -state active
- }
-
- proc challengeProc {} {
-
- global playerList
- set playerList [PlayerServer giveAvailablePlayers]
-
- toplevel .clist
- wm title .clist "Players"
- listbox .clist.list -relief raised -borderwidth 2 \
- -yscrollcommand ".clist.scroll set"
- button .clist.challenge -text "Challenge" -command "selectedProc"
- scrollbar .clist.scroll -command ".clist.list yview"
- pack .clist.challenge -side top -fill x
- pack .clist.scroll -side right -fill y
- pack .clist.list
-
- foreach p $playerList {
- .clist.list insert end [lindex $p 0]
- }
-
- .challenge configure -state disabled
- }
-
- # Construct main window
- button .challenge -text "Challenge ..." -command challengeProc
- button .quit -text "Quit" -command quitProc
- pack .challenge .quit -fill x
- wm title . "TicTacToe: $name"
- wm protocol . WM_DELETE_WINDOW {quitProc}
-